package com.m5;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created by 四毛强 on 2021/7/20.
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class A implements Comparable<A>{

    private String name;
    private int age;
    @Override
    public int compareTo(A o) {
        if(this.age != o.age){
            return this.age-o.age;
        }else{
            return  this.name.compareTo(o.name);
        }
    }

    public static void main(String[] args) {
        ArrayList<A> aa = new ArrayList<A>();
        aa.add(new A("xiao",1));
        aa.add(new A("xiao",8));
        aa.add(new A("xiao",2));
        aa.add(new A("xiao",5));
        aa.add(new A("xiao",6));
        aa.add(new A("xiao",7));
        aa.add(new A("xiao",3));
        Collections.sort(aa);
        for (A a1 : aa) {
            System.out.println(a1.getAge()+a1.getName());
        }
    }


}
